<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="utf-8">
	<title>添加</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport"
		content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<link rel="stylesheet" href="/layui/css/layui.css" media="all">
	<link rel="stylesheet" href="/html/main/config/lib/main.css" media="all">
	<style>
		.layui-form-select {
			width: 100%;
		}
	</style>
</head>

<body id="layui-body-content" class="layui-bg">
	<div id="layui-body-content" class="layui-fluid">
		<div class="layui-card">
			<div class="layui-card-body">
				<form class="layui-form" action="">
					<table class="layui-table">
						<tr>
							<td width="100">
								用户名<span style="color: red;"> *</span>
							</td>
							<td>
								<input type="text" name="username" lay-verify="required" autocomplete="off"
									class="layui-input">
							</td>
						</tr>
						<tr>
							<td>
								密码<span style="color: red;"> *</span>
							</td>
							<td>
								<input type="password" name="password" lay-verify="required" autocomplete="off"
									class="layui-input">
							</td>
						</tr>
						<tr>
							<td>
								真实姓名<span style="color: red;"> *</span>
							</td>
							<td>
								<input type="text" name="truename" lay-verify="required" autocomplete="off"
									class="layui-input">
							</td>
						</tr>
						<tr>
							<td>
								单位名称<span style="color: red;"> *</span>
							</td>
							<td>
								<input type="text" id="depttree" name="depttree" lay-filter="tree" class="layui-input">
								<input type="hidden" name="deptid">
								<input type="hidden" name="deptname">
							</td>
						</tr>
						<tr>
							<td>
								所属科室
							</td>
							<td>
								<input type="text" name="remark" autocomplete="off" class="layui-input">
							</td>
						</tr>
						<tr>
							<td>
								联系电话
							</td>
							<td>
								<input type="text" name="phonenumber" autocomplete="off" class="layui-input">
							</td>
						</tr>
						<tr>
							<td>
								电子邮箱
							</td>
							<td>
								<input type="text" name="email" autocomplete="off" class="layui-input">
							</td>
						</tr>
					</table>
					<div class="layui-form-item">
						<div class="layui-inline item-width">
							<div class="layui-input-block layui-hide">
								<input type="hidden" name="isenabled" value="0">
								<input type="hidden" name="errorcount" value="0">
								<button class="layui-btn" lay-submit lay-filter="YjbtnSave" id="YjbtnSave"
									type="button">提交</button>
							</div>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>

	<script src="/layui/layui.js"></script>
	<script>
		layui.extend({
			treeSelect: '/res/js/extend/treeSelect/treeSelect'
			, main: '../../main/config/lib/main'
		}).define(['form', 'jquery', 'layer', 'main', 'treeSelect'], function (exports) {

			var form = layui.form
				, $ = layui.jquery
				, layer = layui.layer
				, yjUrl = parent.layui.yjUrl
				, admin = parent.layui.admin
				, main = layui.main
				, treeSelect = layui.treeSelect;

			//自定义验证规则
			form.verify({
				dhhm: function (value) {
					if (value != "") {
						if (!/^((0\d{2,3}-\d{7,8})|(1[345678]\d{9}))$/.test(value)) {
							return '请输入正确的联系方式';
						}
					}
				}
				, emailyz: function (value) {
					if (value != "") {
						if (!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$$/.test(value) && !/^0\d{2,3}-?\d{7,8}$/.test(value)) {
							return '请输入正确的电子邮箱';
						}
					}
				}
			});

			treeSelect.render({
				// 选择器
				elem: '#depttree',
				headers: main.headerToken(),
				// 数据
				data: yjUrl.find('system/dept/GetDeptList').urlPath,
				// 异步加载方式：get/post，默认get
				type: 'get',
				// 占位符
				placeholder: '请选择部门或工作组',
				// 是否开启搜索功能：true/false，默认false
				search: true,
				// 点击回调
				click: function (d) {
					$("input[name='deptid']").val(d.current.deptid);
					$("input[name='deptname']").val(d.current.deptname);
				}
			});

		});
	</script>
</body>

</html>